package com.yulongtian.offers.day202301;

import java.util.Arrays;

/**
 * https://leetcode.cn/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-29 22:22
 */
public class Test04 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(minOperations("001011")));
    }

    public static int[] minOperations(String boxes) {
        int len = boxes.length();
        int[] ans = new int[len];
        for (int i = 0; i < boxes.length(); i++) {
            for (int j = 0; j < boxes.length(); j++) {
                if (j == i) {
                    continue;
                }
                if (boxes.charAt(j) == '1') {
                    ans[i] += Math.abs(i - j);
                }
            }
        }
        return ans;
    }
}
